//
//  UITestViewController.m
//  UITest
//

#import "UITestViewController.h"
#import "roundedCornerView.h"

@implementation UITestViewController

- (void)viewDidLoad {

    [super viewDidLoad];

	CGPoint frameCenter = self.view.center;
	float width = 50.0;
	float height = 50.0;
	
	CGRect viewFrame = CGRectMake(frameCenter.x-width, frameCenter.y-height,
								  width*2, height*2);
	
	roundedCornerView *myView = [[roundedCornerView alloc] initWithFrame:viewFrame];
	myView.backgroundColor = [UIColor blueColor];

	// 하위 뷰 생성
	CGRect subViewFrame = CGRectInset(myView.bounds, width/2.0, height/2.0);
	roundedCornerView *mySubview = [[roundedCornerView alloc] initWithFrame:subViewFrame];
	mySubview.backgroundColor = [UIColor yellowColor];
	
	// 자동 크기 변경 마스크 설정
	mySubview.autoresizingMask = UIViewAutoresizingFlexibleWidth
	| UIViewAutoresizingFlexibleHeight;
	[myView addSubview:mySubview];
	
	[[self view] addSubview:myView];

	// 애니메이션 크기 변경
	[UIView beginAnimations:nil context:NULL];
	
	[UIView setAnimationDuration:1.0];
	viewFrame = CGRectInset(viewFrame, -width, -height);
	[myView setFrame:viewFrame];
	
	[UIView commitAnimations];
	
	[mySubview release];
	[myView release];
}

- (void)dealloc {
    [super dealloc];
}

@end
